<div ng-controller="ToProviderListC">
    <div class="bg-light lter b-b wrapper-md">
        <h1 class="m-n font-thin h3">入库单列表</h1>
    </div>
    <div class="wrapper-md" style="text-align: right;">
        <div class="panel panel-default">
            <div class="panel-heading">

                <button class="btn btn-sm btn-default" ng-click="goadd()">
                    <i class="fa fa-plus text"></i>
                    <span class="text">添加</span>
                </button>
            </div>
            <div class="table-responsive text-center" >
                <table id="example1" class="table table-striped b-t b-light table-bordered">
                    <thead>
                    <tr>
                        <th style="text-align: center;">仓库</th>
                        <th style="text-align: center;">创建人</th>
                        <th style="text-align: center;">入库时间</th>
                        <th style="text-align: center;">入库单类型</th>
                        <th style="text-align: center;">操作</th>

                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="item in pageData.Data">
                        <td>{{item.Provider.Name}}</td>
                        <td>{{item.Creater.Name}}</td>
                        <td>{{item.CreateTime}}</td>
                        <td ng-if="item.From ==0">手动创建</td>
                        <td ng-if="item.From ==1">采购创建</td>
                        <td ng-if="item.From ==2">退货</td>
                        <td ng-if="item.From ==3">冲红单</td>
                        <td>
                            <button class="btn btn-sm btn-default" ng-click="$state.go('app.Provider_ToProviderDetail', { 'id': item.Id })">
                                <i class="fa fa-edit text"></i>
                                <span class="text">编辑</span>
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>
                <!--<div class="panel-heading" ng-include="'/htm/tpl/Supplier/Paging.html'"></div>-->
                <div class="panel-heading" my-pagination get-page-data="getData" mypagedata="pageData"></div>
            </div>
        </div>
    </div>
</div>
<script>
    angular.module('app')//非标优惠
            .controller("ToProviderListC", function ($scope, $state, $http,toSave) {
                $scope.pageData = {};
                $scope.pageData.Page = 0;

                $scope.pageData.Rows = $scope.defPageRows;
                //
                $scope.getData = function (p, r) {
                    if (p) {
                        p = p < 1 ? 1 : p;
                    } else p = 1;
                    if (r) {
                    } else r = $scope.defPageRows;
                    toSave.save_pages_lis(p,r);//保存当前页码和条数
                    $http({
                        url: "../api/Provider/GetWarehouseEntrys?providerId=&page=" + p + "&rows=" + r,
                        method: "GET"
                    })
                            .then(function (res) {
                                $scope.pageData = res.data;
                                console.log($scope.pageData);
                            })
                            .then(function (error) {
                                if (error) {
                                    alert("数据获取失败");
                                }
                            });
                };
                console.log(toSave.get_pages());
                $scope.getData(toSave.get_pages(), $scope.pageData.Rows);
                $scope.goadd = function(){
                    $state.go('app.Provider_ToProvider');
                }
            })

</script>
<script src="js/services/toSave.js"></script>
